package com.tianquan.Thread;/**
 * @author starsea
 * @date 2024-10-15 上午10:11
 */

import java.util.concurrent.CountDownLatch;
import java.util.concurrent.atomic.AtomicLong;

/**
 *@BelongsProject: uploaddemo
 *@BelongsPackage: com.tianquan.Thread
 *@Author: tianquan
 *@CreateTime: 2024-10-15  10:11
 *@Description: 测试
 *@Version: 1.0
 */

public class BitwiseWith {

    public static void main(String[] args) throws InterruptedException {

        CountDownLatch countDownLatch = new CountDownLatch(2);
        AtomicLong l = new AtomicLong(0L);
        AtomicLong l1 = new AtomicLong(0L);

        Thread thread = new Thread(() -> {
            long start = System.currentTimeMillis();
            for (int i = 1; i < 100000000; i++) {
                int i1 = countDownLatch.hashCode() & i;
            }
            countDownLatch.countDown();
            long end = System.currentTimeMillis();
            l.set(end - start);
        });

        Thread thread1 = new Thread(() -> {
            long start = System.currentTimeMillis();
            for (int i = 1; i < 100000000; i++) {
                int i1 = countDownLatch.hashCode() % i;
            }
            countDownLatch.countDown();
            long end = System.currentTimeMillis();
            l1.set(end - start);
        });
        thread.start();
        thread1.start();

        countDownLatch.await();
        System.out.println(l.get() + "& : %" + l1.get());


    }

}
